<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="js/vue.js"></script>
</head>

<body>
    <div id="app">
        <label>姓名：</label>
        <input id="name" type="text" v-model="name" @keyup.F2="pressF2">
    </div>
    <script>
        Vue.config.keyCodes.f2 = 113;
        var vm = new Vue({
            el: '#app',
            data: {
                name: ''
            },
            methods: {
                pressF2() {
                    console.log('name: ' + name + '是通过F2按键获得的')
                }
            }
        })
    </script>
</body>

</html>